package com.tc.zigbee.mt;

import com.tc.zigbee.mt.income.ActiveEndpointResponse;
import com.tc.zigbee.mt.income.AfDataConfirm;
import com.tc.zigbee.mt.income.AfDataRequestResp;
import com.tc.zigbee.mt.income.AfIncomeMessage;
import com.tc.zigbee.mt.income.ComplexDescriptorResponse;
import com.tc.zigbee.mt.income.DeviceAnnounceIndication;
import com.tc.zigbee.mt.income.IeeeResponse;
import com.tc.zigbee.mt.income.IncomeMessage;
import com.tc.zigbee.mt.income.NodeDescriptorResponse;
import com.tc.zigbee.mt.income.PowerDescriptorResponse;
import com.tc.zigbee.mt.income.SimpleDescriptorResponse;

public class IncomeMessageParser {
	//Length = 0x06-0x53  Cmd0 = 0x45  Cmd1 = 0x85  SrcAddr  Status  NwkAddr  ActiveEPCount 
	static public IncomeMessage parse(MtCommand c){
		if(c.cmd0 == (byte)0x45 && c.cmd1 == (byte)0x81)
			return new IeeeResponse(c.command);
		if(c.cmd0 == (byte)0x45 && c.cmd1 == (byte)0x85)
			return new ActiveEndpointResponse(c.command);
		if(c.cmd0 == (byte)0x45 && c.cmd1 == (byte)0x84)
			return new SimpleDescriptorResponse(c.command);
		if(c.cmd0 == (byte)0x45 && c.cmd1 == (byte)0x82)
			return new NodeDescriptorResponse(c.command);
		if(c.cmd0 == (byte)0x45 && c.cmd1 == (byte)0x83)
			return new PowerDescriptorResponse(c.command);
		if(c.cmd0 == (byte)0x45 && c.cmd1 == (byte)0x87)
			return new ComplexDescriptorResponse(c.command);
		if(c.cmd0 == (byte)0x44 && c.cmd1 == (byte)0x81)
			return new AfIncomeMessage(c.command);
		if(c.cmd0 == (byte)0x44 && c.cmd1 == (byte)0x80)
			return new AfDataConfirm(c.command);
		if(c.cmd0 == (byte)0x64 && c.cmd1 == (byte)0x01)
			return new AfDataRequestResp(c.command);
		if(c.cmd0 == (byte)0x45 && c.cmd1 == (byte)0xc1)
			return new DeviceAnnounceIndication(c.command);
		return null;
	}
}
